from django.contrib.auth.hashers import make_password, check_password
from django.db import models


class UserPeo(models.Model):
    u_name = models.CharField(max_length=32, verbose_name="姓名", unique=True)
    u_gender = models.BooleanField(default=False, verbose_name="性别")
    # u_age = models.IntegerField()
    _u_password = models.CharField(max_length=256)

    @property
    def u_password(self):
        raise Exception("用户密码不可显示")

    @u_password.setter
    def u_password(self, password):
        self._u_password = make_password(password)

    def verity_password(self, password):
        # print(make_password(password))
        # print(self._u_password)
        return check_password(password, self._u_password)
